<?php
namespace app\admin\controller;
use think\Db;
use think\Request;

class Hottback extends Base
{
    public function _initialize()
    {
        // 调用父类前置方法
        parent::_initialize();

        // 登录校验
        $this->IsLogin();
    }


    public function index(Request $request)
    {
        if ($request->isAjax()){
            $proxy_list = Db::name('proxy')->where('is_delete_time',0)->select();
            $count = Db::name('proxy')->where('is_delete_time',0)->count();
            foreach ($proxy_list as $key=>$value){
                $proxy_list[$key]['id'] = $value['proxy_id'];
            }
            if (!empty($proxy_list)){
                echo json_encode(['code'=>0,'msg'=>'ok','data'=>$proxy_list,'count'=>$count]);
            }
        }else{
            return $this->fetch();

        }



    }
    public function do_fix(Request $request)
    {
        $param = $request->param();
        if (!empty($param)){
            $re = Db::name('proxy')->where('proxy_id',$param['id'])->update(['beishu'=>$param['beishu'],'upd_time'=>time()]);
        }
        if ($re){
            echo json_encode(['code'=>0,'msg'=>$param['beishu'].'倍更改成功']);
        }else{
            echo json_encode(['code'=>-1,'msg'=>'更改失败,请重试']);
        }
    }
    public function fix(Request $request)
    {
        $param = $request->param();
        $info = Db::name('proxy')->where('proxy_id',$param['id'])->find();
        $this->assign('info',$info);
        return $this->fetch();
    }

}